import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tailwindcss from "tailwindcss"
import path from 'path';

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, 'src') // 路径别名
    }
  },
  // 新增 css 配置
  css: {
    postcss: {
      plugins: [tailwindcss()],
    }
  },
  build: {
    outDir: path.resolve(__dirname, 'dist'),
    rollupOptions: {
      input: {
        main: path.resolve(__dirname, 'index.html')
      }
    },
    optimizeDeps: {
      include: ['@/index/index.tsx'], // 使用路径别名
    }
  },
  server: {
    port: 3000,
    open: true,
    base: '/', // 确保 base 路径正确
  },
});